import request from '../utils/request'
import type { User } from '../types/user'

export const userApi = {
  // 用户登录
  login(data: { username: string; password: string }) {
    return request.post<User>('/auth/login', data)
  },

  // 用户注册
  register(data: Partial<User> & { phone: string }) {
    return request.post<User>('/users', data)
  },

  // 获取当前用户信息
  getCurrentUser() {
    return request.get<User>('/users/current')
  },

  // 更新用户信息
  updateUser(id: number, data: Partial<User>) {
    return request.put<User>(`/users/${id}`, data)
  },

  // 修改密码
  changePassword(data: { oldPassword: string; newPassword: string }) {
    return request.put('/users/password', data)
  },

  getUser(id: number) {
    return request.get<User>(`/users/${id}`)
  }
} 